package com.g9.blog.service.impl;

import com.g9.blog.entity.ArticleLike;
import com.g9.blog.repository.LikeRepository;
import com.g9.blog.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Auther: Graycat
 * @Date: 2020/9/14 17:19
 * Create by lwj.
 */
@Service
@Transactional
public class LikeServiceImpl implements LikeService {
    @Autowired
    LikeRepository likeRepository;
    @Override
    public List<ArticleLike> ifLikeOrNot(int articleId, int userId) {
      return likeRepository.findAllByArticleIdAndUserId(articleId,userId);
    }

    @Override
    public void save(ArticleLike like) {
        likeRepository.save(like);
    }
}
